package cn.edu.scau.cmi.chenyuanying.classAdapter;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class AdapterOfClass extends SortUtil implements ClassAdapterTarget {
	@Override
	public void insertStudent(Student stu) {
		students.add(stu);
		List<Integer> idList = new ArrayList<>();
		List<Student> newList = new ArrayList<>();
		for(Student t : students) {
			newList.add(t);
			idList.add(t.getId());
		}
		sortInt(idList);
		for(Student t : newList) {
			int pos = Arrays.binarySearch(idList.toArray(), t.getId());
			students.set(pos, t);
		}
	}
}
